package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.annotation.OperLog;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.orderB.entity.CustomerMaintainFeeAttach;
import com.egao.orderB.service.CustomerMaintainFeeAttachService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 *
 * 货代附加费维护
 * @author : Doman
 * @date : 2021-07-15 12:46:52
 * @version ：1.0
 */

@Api(tags = "货代附加费维护")
@RestController
@RequestMapping("/api/orderB/customerMaintainFeeAttach")
public class CustomerMaintainFeeAttachController extends BaseController {

	@Autowired
	private CustomerMaintainFeeAttachService customerMaintainFeeAttachService;

	/**
	 * 分页查询列表
	 */
//	@PreAuthorize("hasAuthority('orderB:customerMaintainFeeAttach:list')")
    //@OperLog(value = "货代附加费维护", desc = "分页查询")
    @ApiOperation(value ="分页查询货代附加费维护",notes = "" +
        "limit:每页显示几行 必填\n" +
        "page:第几页 必填\n" +
        "customerId:客户id\n" +
        " \n\n\n" +
        "返回的结果:\n" +
        "id:id\n" +
        "customerId:客户名称\n" +
        "name:费用名\n" +
        "pinyin:费用名,标准 转拼音\n" +
        "standard:标准\n" +
        "boxType:箱型\n" +
        "price:金额\n" +
        "type:类型 平台\n" +
        "atModules 模块 运费,提进,其他,单项,采购,报关费,易港通,财务报销\n" +
        "longitude:经度\n" +
        "latitude:纬度\n" +
        "radius:半径 默认米\n" +
        "yardDock:类型: 堆场,港口\n" +
        "remark:备注\n" +
        "createTime:创建时间\n" +
        "createUser:创建人\n" +
        "updateTime:更新时间\n" +
        "updateUser:更新人\n" +
        "",httpMethod = "POST")
    @ApiPageParam
    @PostMapping("/page")
    public JsonResult page(PageResult2<T> page, CustomerMaintainFeeAttach customerMaintainFeeAttach) throws Exception{
        return customerMaintainFeeAttachService.list(page, customerMaintainFeeAttach, getLoginUser());
    }

    /**
     * 查询全部货代附加费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFeeAttach:list')")
    //@OperLog(value = "货代附加费维护", desc = "查询全部")
    @ApiOperation("查询全部货代附加费维护")
    @PostMapping("/list")
    public JsonResult list(CustomerMaintainFeeAttach customerMaintainFeeAttach){
        return customerMaintainFeeAttachService.list(customerMaintainFeeAttach, getLoginUser());
    }

    /**
     * 根据id查询货代附加费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFeeAttach:list')")
    //@OperLog(value = "货代附加费维护", desc = "根据id查询")
    @ApiOperation("根据id查询货代附加费维护")
    @PostMapping("/get")
    public JsonResult get(CustomerMaintainFeeAttach customerMaintainFeeAttach) {
        return customerMaintainFeeAttachService.getById(customerMaintainFeeAttach);
		// 使用关联查询
        //PageParam<customerMaintainFeeAttach> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<customerMaintainFeeAttach> records = customerMaintainFeeAttachService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加货代附加费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFeeAttach:save')")
    @OperLog(value = "货代附加费维护", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加货代附加费维护",notes = "" +
            "customerId:客户名称\n" +
            "name:费用名\n" +
            "standard:标准\n" +
            "boxType:箱型\n" +
            "price:金额\n" +
            "type:类型 平台 司机\n" +
            "atModules:模块 运费,提进,其他,单项,报关费,采购\n" +
            "longitude:经度\n" +
            "latitude:纬度\n" +
            "radius:半径 默认米\n" +
            "yardDock:类型: 堆场,港口\n" +
            "remark:备注\n" +
        "",httpMethod = "POST")
    @PostMapping("/save")
    public JsonResult save(Model model, CustomerMaintainFeeAttach customerMaintainFeeAttach) {
        return customerMaintainFeeAttachService.save(customerMaintainFeeAttach, getLoginUser());
    }

    /**
     * 修改货代附加费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFeeAttach:update')")
    @OperLog(value = "货代附加费维护", desc = "修改", param = false, result = true)
    @ApiOperation(value ="修改货代附加费维护",notes = "" +
            "id:id\n" +
            "name:费用名\n" +
            "standard:标准\n" +
            "boxType:箱型\n" +
            "price:金额\n" +
            "type:类型 平台 司机\n" +
            "atModules:模块 运费,提进,其他,单项,报关费,采购\n" +
            "longitude:经度\n" +
            "latitude:纬度\n" +
            "radius:半径 默认米\n" +
            "yardDock:类型: 堆场,港口\n" +
            "remark:备注\n" +
        "",httpMethod = "POST")
    @PostMapping("/update")
    public JsonResult update(Model model, CustomerMaintainFeeAttach customerMaintainFeeAttach) {
        return customerMaintainFeeAttachService.update(customerMaintainFeeAttach, getLoginUser());
    }

    /**
     * 删除货代附加费维护
     */
//    @PreAuthorize("hasAuthority('orderB:customerMaintainFeeAttach:remove')")
    @OperLog(value = "货代附加费维护", desc = "删除", result = true)
    @ApiOperation("删除货代附加费维护")
    @PostMapping("/remove")
    public JsonResult remove(CustomerMaintainFeeAttach customerMaintainFeeAttach ) {
        return customerMaintainFeeAttachService.remove(customerMaintainFeeAttach, getLoginUser());
    }

    /**
     * excel导入用户
     */
    @OperLog(value = "货代附加费维护", desc = "excel导入", param = false, result = true)
    @ApiOperation("excel导入货代附加费维护")
    @Transactional
    @PostMapping("/import")
    public JsonResult importBatch(MultipartFile file) {
        return customerMaintainFeeAttachService.importBatch(file, getLoginUser());
    }

    /**
     * 批量添加货代附加费维护
     */
    /**@RequiresPermissions("orderB:customerMaintainFeeAttach:save")
    @OperLog(value = "货代附加费维护", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<CustomerMaintainFeeAttach> list) {
        if (customerMaintainFeeAttachService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改货代附加费维护
     */
    /**@RequiresPermissions("orderB:customerMaintainFeeAttach:update")
    @OperLog(value = "货代附加费维护", desc = "批量修改", result = true)
    @ResponseBody
    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<CustomerMaintainFeeAttach> batchParam) {
        if (batchParam.update(customerMaintainFeeAttachService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除货代附加费维护
     */
    /**@RequiresPermissions("orderB:customerMaintainFeeAttach:remove")
    @OperLog(value = "货代附加费维护", desc = "批量删除", result = true)
    @ResponseBody
    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (customerMaintainFeeAttachService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
